package test.baojia.act.business;

import com.alibaba.fastjson.JSONObject;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.support.ui.ExpectedConditions;

import java.util.HashMap;
import java.util.Properties;

/**
 * 判断报价单基本信息中文本框和复选框是否只读。
 */
public class FullFormReadonlyBusiness extends Business {

    @Override
    public void run(JSONObject context, WebDriver driver, Properties resource, JSONObject parentContext) throws  Exception {
        super.run(context, driver, resource, parentContext);

        By remarkBy = By.id("remark");
        //该字段本来可录，现在不可录。以此判断表单刷新。
        this.newWebDriverWait(null).until(
                ExpectedConditions.presenceOfElementLocated(remarkBy)
        );
        this.newWebDriverWait(null).until(
                ExpectedConditions.attributeToBeNotEmpty(driver.findElement(remarkBy) , "disabled")
        );

        final String jsScript = this.makeDefaultJsScript(new HashMap());

        this.newWebDriverWait(null).until(
                ExpectedConditions.javaScriptThrowsNoExceptions(jsScript)
        );
    }
}
